import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-05-09
 * Time: 14:06
 */
/*class Person implements Comparable<Person>{
    public String name;
    public String gender;
    public int age;

    Person(String name,String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public String toString() {
        return "[" + this.name + ":" + this.gender + " "+ this.age + "]";
    }


    @Override
    public int compareTo(Person o) {
        return this.age-o.age;
    }
}

class PersonAgeComparator implements Comparator<Person> {

    @Override
    public int compare(Person o1, Person o2) {
        return o2.compareTo(o1);
    }
}

public class Test2 {

    public static void main(String[] args) {
            Person[] person = new Person[] {
                new Person("泡泡","女",19),
                new Person("西西","男",33),
                new Person("柚柚","女",25),
                new Person("球球","男",25)
        };

        //定义比较器对象
        PersonAgeComparator tor = new PersonAgeComparator();
        //使用比较器对象进行比较
        System.out.println(tor.compare(person[0],person[1]));
    }
}
*/